//
//  statusModel.swift
//  SinaWeiBo
//
//  Created by dengchen on 15/11/14.
//  Copyright © 2015年 name. All rights reserved.
//

import UIKit

class statusModel: NSObject {
    
    //微博创建时间
    var created_at:String?
    
    //微博信息内容
    var text:String?
    //	微博ID
    var id: Int = 0
    //微博来源
    var source:String?
    
    //微博作者的用户信息字段
    var user:statusUserModel?
    
    //转发微博字段
    var retweeted_status:statusModel?
    
    var pic_urls:[[String:String]]?
    
    var imageURLs:[NSURL]? {
        guard let urls = pic_urls else {
            return nil
        }
        
        var tempURLs = [NSURL]()
        
        for url in urls {
            tempURLs.append(NSURL(string: url["thumbnail_pic"]!)!)
        }
        
        return tempURLs
    }
    
    init(dict:[String:AnyObject]) {
        super.init()
        setValuesForKeysWithDictionary(dict)
    }
    
    override func setValue(value: AnyObject?, forKey key: String) {
        
        switch key {
            
        case "user":
                if let dict = value as? [String:AnyObject]{
                    user = statusUserModel(dict: dict)
                }
        case "retweeted_status":
                if let dict = value as? [String:AnyObject]{
                    retweeted_status = statusModel(dict: dict)
                }
        default:
                super.setValue(value, forKey: key)
        }
    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {}

}
